<script setup lang="ts">
import type {PopoverBtnPropsType} from './types'

withDefaults(defineProps<PopoverBtnPropsType>(), {
  iconProps: {} as any,
  text: '',
  btnProps: {} as any,
  click: () => {},
  collapse: false,
  disabled: false,
  tooltipProps: {} as any,
  popoverProps: {} as any
})

const slots = useSlots()
</script>

<template>
  <n-popover
    v-bind="{
      disabled: !slots['default'],
      ...popoverProps,
    }"
  >
    <template #trigger>
      <slot name="trigger">
        <x-collapse-btn
          :icon-props="iconProps"
          :text="text"
          :btn-props="btnProps"
          :click="click"
          :collapse="collapse"
          :disabled="disabled"
          :tooltip-props="tooltipProps"
        >
          <template v-if="slots['trigger-btn']" #btn>
            <slot name="trigger-btn" />
          </template>
          <template v-if="slots['trigger-btn-icon']" #btn-icon>
            <slot name="trigger-btn-icon" />
          </template>
        </x-collapse-btn>
      </slot>
    </template>
    <template v-if="slots['default']" #default>
      <slot name="default" />
    </template>
  </n-popover>
</template>

<style scoped lang="scss">

</style>
